package org.example.booksystem.controller;


import org.example.booksystem.moudel.BookInfo;
import org.example.booksystem.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/book")
@RestController
public class BookSystemController {

    private BookService bookService ;
    @Autowired
    public void setBookService(BookService bookService) {
        this.bookService = bookService;
    }

    @RequestMapping("/login")
    public boolean login(String userName , String password){
        if(!StringUtils.hasLength(userName) || !StringUtils.hasLength(password)){
            return false ;
        }
        if("zhangsan".equals(userName) && "12345".equals(password)){
            return true ;
        }
        return false ;
    }

    @RequestMapping("/getList")
    public List<BookInfo> getList(){
        return bookService.getList() ;
    }

}
